﻿using System;
using UnityEngine;

namespace Valve.VR.InteractionSystem
{
	// Token: 0x0200064F RID: 1615
	[RequireComponent(typeof(Interactable))]
	public class InteractableExample : MonoBehaviour
	{
		// Token: 0x060028F9 RID: 10489 RVA: 0x000EE3B8 File Offset: 0x000EC5B8
		private void Awake()
		{
			this.textMesh = base.GetComponentInChildren<TextMesh>();
			this.textMesh.text = "No Hand Hovering";
		}

		// Token: 0x060028FA RID: 10490 RVA: 0x000EE3D8 File Offset: 0x000EC5D8
		private void OnHandHoverBegin(Hand hand)
		{
			this.textMesh.text = "Hovering hand: " + hand.name;
		}

		// Token: 0x060028FB RID: 10491 RVA: 0x000EE3F8 File Offset: 0x000EC5F8
		private void OnHandHoverEnd(Hand hand)
		{
			this.textMesh.text = "No Hand Hovering";
		}

		// Token: 0x060028FC RID: 10492 RVA: 0x000EE40C File Offset: 0x000EC60C
		private void HandHoverUpdate(Hand hand)
		{
			if (hand.GetStandardInteractionButtonDown() || (hand.controller != null && hand.controller.GetPressDown(EVRButtonId.k_EButton_Grip)))
			{
				if (hand.currentAttachedObject != base.gameObject)
				{
					this.oldPosition = base.transform.position;
					this.oldRotation = base.transform.rotation;
					hand.HoverLock(base.GetComponent<Interactable>());
					hand.AttachObject(base.gameObject, this.attachmentFlags, string.Empty);
				}
				else
				{
					hand.DetachObject(base.gameObject, true);
					hand.HoverUnlock(base.GetComponent<Interactable>());
					base.transform.position = this.oldPosition;
					base.transform.rotation = this.oldRotation;
				}
			}
		}

		// Token: 0x060028FD RID: 10493 RVA: 0x000EE4DC File Offset: 0x000EC6DC
		private void OnAttachedToHand(Hand hand)
		{
			this.textMesh.text = "Attached to hand: " + hand.name;
			this.attachTime = Time.time;
		}

		// Token: 0x060028FE RID: 10494 RVA: 0x000EE504 File Offset: 0x000EC704
		private void OnDetachedFromHand(Hand hand)
		{
			this.textMesh.text = "Detached from hand: " + hand.name;
		}

		// Token: 0x060028FF RID: 10495 RVA: 0x000EE524 File Offset: 0x000EC724
		private void HandAttachedUpdate(Hand hand)
		{
			this.textMesh.text = "Attached to hand: " + hand.name + "\nAttached time: " + (Time.time - this.attachTime).ToString("F2");
		}

		// Token: 0x06002900 RID: 10496 RVA: 0x000EE56C File Offset: 0x000EC76C
		private void OnHandFocusAcquired(Hand hand)
		{
		}

		// Token: 0x06002901 RID: 10497 RVA: 0x000EE570 File Offset: 0x000EC770
		private void OnHandFocusLost(Hand hand)
		{
		}

		// Token: 0x04002917 RID: 10519
		private TextMesh textMesh;

		// Token: 0x04002918 RID: 10520
		private Vector3 oldPosition;

		// Token: 0x04002919 RID: 10521
		private Quaternion oldRotation;

		// Token: 0x0400291A RID: 10522
		private float attachTime;

		// Token: 0x0400291B RID: 10523
		private Hand.AttachmentFlags attachmentFlags = Hand.AttachmentFlags.DetachFromOtherHand | Hand.AttachmentFlags.ParentToHand;
	}
}
